﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kaiser.Modules.Cubic.DomainModel.News;
using Kaiser.Modules.Cubic.Repositories;

namespace Kaiser.Repositories.iBatis.CUBIC
{
    public class NewsRepositorie : INewsRepositorie
    {
        private IBatisHepler IBatisHepler = null;
        public NewsRepositorie()
        {
            IBatisHepler = new BatisHepler("SQLMap.CUBIC.config");
        }

        public Modules.Cubic.DomainModel.News.NewsDetail GetNewsByCode(string newsCode)
        {
            NewsDetail result = IBatisHepler.ExcuteSelectObj("GetNewsByCode", newsCode) as NewsDetail;
            return result;
        }

        /// <summary>
        /// 返回新闻详细内容
        /// </summary>
        /// <param name="newsId"></param>
        /// <returns></returns>
        public NewsDetail GetNews(string newsId)
        {
            NewsDetail result = IBatisHepler.ExcuteSelectObj("GetNews", newsId) as NewsDetail;
            return result;
        }


        public NewsCategory GetNewsCategoryByCode(string categoryCode)
        {
            NewsCategory result = IBatisHepler.ExcuteSelectObj("GetNewsCategoryByCode", categoryCode) as NewsCategory;
            return result;
        }

        public IList<NewsCategory> GetAll()
        {
            var result = IBatisHepler.ExcuteSelectForList<NewsCategory>("NewsCategory.GetAll",null);
            return result;
        }
    }
}
